<?php

namespace app\api\controller;

use app\facade\Basic;
use think\Request;
use app\api\service\Index as IndexService;
use app\api\service\ProductMerge as ProductMergeService;
use app\api\service\CCNames as CCNamesService;

class Index extends BaseController
{

    protected $service;
    public function __construct()
    {
        $this->service = new IndexService();
    }

    public function index()
    {
        return Basic::json(['message' => 'Hello, World!']);
    }

    /**
     * @describe
     * @author: Bobo
     * @date: 2025-03-24 12:00:06 
     * @param [type] @required
     * @return Renderable
     */
    public function complex(Request $request)
    {
        $lang = $request->header('think-lang') ?? 'en';
        $result = $this->service->complex($lang);
        return Basic::dataJson(0, 'common.success', $result);
    }
    /**
     * @describe 获取公共分类
     * @author: Bobo
     * @date: 2025-04-4 10:37:28
     * @param [type] @required
     * @return Renderable
     */
    public function publicCategories(Request $request)
    {
        $lang = $request->header('think-lang') ?? 'en';
        $result = $this->service->publicCategories($lang);
        return Basic::dataJson(0, 'common.success', $result);
    }



    /**
     * @describe
     * @author: Bobo
     * @date: 2025-04-24 13:09:31 
     * @param [type] @required
     * @return Renderable
     */
    public function clearCache(Request $request)
    {
        $type = $request->param('type') ?? 1;
        $result = $this->service->clearCache($type);
        return Basic::dataJson(0, 'common.success', $result);
    }
}
